home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1997 January: Mac OS SDK / Dev.CD Jan 97 SDK2.toast / Development Kits (Disc 2) / OpenDoc Development Framework / ODFDev / ODF / Internet / FWCyStrm.h < prev    next >
Encoding:
Text File  |  1996-09-17  |  3.6 KB  |  139 lines  |  [TEXT/MPS ]

  1. //========================================================================================
  2. //
  3. //    File:                FWCyStrm.h
  4. //    Release Version:    $ ODF 2 $
  5. //
  6. //    Copyright:    (c) 1993 - 1996 by Apple Computer, Inc., all rights reserved.
  7. //
  8. //========================================================================================
  9.  
  10. #ifndef FWCYSTRM_H
  11. #define FWCYSTRM_H
  12.  
  13. #ifndef FWSOMPTR_H
  14. #include "FWSOMPtr.h"
  15. #endif
  16.  
  17. //-----------------------------------------------------------------------------
  18. // Includes and Class Declarations
  19. //-----------------------------------------------------------------------------
  20.  
  21. #ifndef SOM_FW_OCyberSink_xh
  22. #include <SLCySink.xh>
  23. #endif
  24.  
  25. class FW_OSink;
  26. class CyberStream;
  27. class CyberItem;
  28. class CyberSession;
  29.  
  30. //-----------------------------------------------------------------------------
  31. // Cyberdog Utilities
  32. //-----------------------------------------------------------------------------
  33.  
  34. // Constant: if (status & FW_kCyberStreamDone) ...
  35. extern const short FW_kCyberStreamDone; // = kCDErrorOccurred | kCDDownloadComplete | kCDAbortComplete
  36.  
  37. //========================================================================================
  38. // Class FW_CCyberStream
  39. //========================================================================================
  40.  
  41. /*
  42.     FW_CCyberStream is an envelope class for CyberStream.
  43.     It ensures that CyberStream will be deleted when you're done
  44.     with it. It also makes sure that Abort is properly called if 
  45.     the stream has not been fully read.
  46. */
  47.  
  48. class FW_CCyberStream {
  49. public:
  50.                     FW_DECLARE_AUTO (FW_CCyberStream)
  51.                     FW_CCyberStream (CyberStream* cs = kODNULL);
  52.                     ~FW_CCyberStream ();
  53.     FW_CCyberStream& operator= (CyberStream* cs);
  54.     void             Assign (CyberStream* cs);
  55.     CyberStream*     operator -> ();
  56.                     operator CyberStream* ();
  57. private:
  58.     CyberStream*     fStream;
  59.     // Copy construction and assignment are not supported.
  60. private:
  61.                     FW_CCyberStream (const FW_CCyberStream& );
  62.     FW_CCyberStream& operator= (const FW_CCyberStream& );
  63. };
  64.  
  65. //========================================================================================
  66. // Class FW_PCyberSink
  67. //========================================================================================
  68.  
  69. /*
  70.     FW_PCyberSink is an envelope class for FW_OCyberSink (which
  71.     itself uses a CyberStream)
  72. */
  73.  
  74. class FW_PCyberSink: public FW_TSOMPtr<FW_OCyberSink> {
  75. public:
  76.                     FW_PCyberSink (Environment* ev, CyberStream* cs);
  77.                     ~FW_PCyberSink ();
  78. };
  79.  
  80. //========================================================================================
  81. // Class FW_CCyberBuffer
  82. //========================================================================================
  83.  
  84. /*
  85.     FW_CCyberBuffer is an envelope class for a buffer aquired from a
  86.     CyberStream. This ensures it is released back to the stream.
  87. */
  88.  
  89. class FW_CCyberBuffer {
  90. public:
  91.                     FW_DECLARE_AUTO (FW_CCyberBuffer)
  92.                     FW_CCyberBuffer (Environment* ev, CyberStream* cs);
  93.                     ~FW_CCyberBuffer ();
  94.     Size            GetSize()            { return fSize; }
  95.     Ptr                GetBuffer()            { return fBuffer; }
  96. private:
  97.     CyberStream*     fStream;
  98.     Ptr             fBuffer;
  99.     Size             fSize;
  100. };
  101.  
  102. //-----------------------------------------------------------------------------
  103. // FW_CCyberStream Inlines
  104. //-----------------------------------------------------------------------------
  105.  
  106. inline 
  107. FW_CCyberStream::FW_CCyberStream (CyberStream* cs)
  108. :    fStream(cs)
  109. {
  110. }
  111.  
  112. inline 
  113. FW_CCyberStream::~FW_CCyberStream ()
  114. {
  115.     Assign(kODNULL);
  116. }
  117.  
  118. inline 
  119. FW_CCyberStream& FW_CCyberStream::operator= (CyberStream* cs)
  120. {
  121.     Assign(cs);
  122.     return *this;
  123. }
  124.  
  125. inline CyberStream* 
  126. FW_CCyberStream::operator -> ()
  127. {
  128.     return fStream;
  129. }
  130.  
  131. inline 
  132. FW_CCyberStream::operator CyberStream* ()
  133. {
  134.     return fStream;
  135. }
  136.  
  137. #endif // _FW_CyberdogStreamUtilities_
  138.  
  139.